package com.caishi.lkx.exam.vo;

import com.caishi.lkx.exam.QuestionCollectionBlockItem;
import com.caishi.lkx.exam.ienum.type.QuestionCollectionType;
import com.caishi.lkx.exam.records.RecordsCollectType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Getter
@Setter
@Schema(title = "试题集合")
public class QuestionCollectVo {
    @Schema(name = "集合id")
    private Serializable id;

    @Schema(name = "集合名字")
    private String name;

    @Schema(name = "最后做题id")
    private String lastId;

    @Schema(name = "集合类型")
    private QuestionCollectionType type;

    @Schema(name = "记录集合类型")
    private RecordsCollectType recordsType;

    @Schema(name = "试题集合")
    private List<QuestionCollectionBlockItemVo> content;

    @Getter
    @Setter
    @Schema(title = "试题集合分类")
    public static class QuestionCollectionBlockItemVo {

        public QuestionCollectionBlockItemVo() {
        }

        public QuestionCollectionBlockItemVo(QuestionCollectionBlockItem blockItem) {
            this.tyName = blockItem.getTyName();
            this.desc = blockItem.getDesc();
            this.score = blockItem.getScore();
            this.sort = blockItem.getSort();
        }


        /**
         * 聚合小类型名称
         */
        @Schema(name = "聚合分类名称")
        private String tyName;

        /**
         * 类型描述
         */
        @Schema(name = "集合描述")
        private String desc;

        /**
         * 题型总分
         */
        @Schema(name = "当前聚合提醒总分")
        private BigDecimal score;

        /**
         * 排序
         */
        @Schema(name = "聚合排序")
        private Integer sort;

        /**
         * 试题
         */
        @Schema(name = "试题列表")
        private List<QuestionCollectionItemVo> qs;

        @Getter
        @Setter
        @Schema(name = "试题数据")
        public static class QuestionCollectionItemVo extends QuestionVo {
            public QuestionCollectionItemVo() {
            }

            public QuestionCollectionItemVo(QuestionCollectionBlockItem.QuestionCollectionItem questionCollectionItem) {
                this.id = questionCollectionItem.getId();
                this.sort = questionCollectionItem.getSort();
                this.score = questionCollectionItem.getScore();
            }

            /**
             * 试题id
             */
            @Schema(name = "试题id")
            private String id;

            /**
             * 排序
             */
            @Schema(name = "试题排序")
            private Integer sort;

            /**
             * 分数
             */
            @Schema(name = "试题分数")
            private BigDecimal score;


            public Integer getSort() {
                return sort == null ? Integer.MAX_VALUE : sort;
            }
        }
    }
}
